import { createApp } from 'vue';
import App from './App.vue';
import router from '@/router';
import pinia from '@/stores';
import '@/assets/main.less';
import 'virtual:svg-icons-register';
// 引入SvgIcon.vue组件
import SvgIcon from '@/components/SvgIcon.vue';
// 全局样式文件
import '@/styles/index.scss'; // global css
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
// import animate from 'animate.css'
import ElementPlus from 'element-plus';

import zhCn from 'element-plus/es/locale/lang/zh-cn';

const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.use(ElementPlus, {
  locale: zhCn
});

// 引入全局过滤器
// main.js
app.config.globalProperties.$filters = {
  formatTaskName: function (val) {
    if (val) {
      const card = val;
      if (card.length > 10) {
        return card.substr(0, 10) + '...';
      } else {
        return card;
      }
    }
  }
};

// 将SvgIcon.vue组件注册为全局组件
app.component('SvgIcon', SvgIcon);
app.use(router);
app.use(pinia);

// app.use(animate)

app.mount('#app');
